package com.yunang.officialweb.service.impl;

import com.yunang.officialweb.entity.ProductionDesc;
import com.yunang.officialweb.entity.TotalDesc;
import com.yunang.officialweb.mapper.HomeMapper;
import com.yunang.officialweb.mapper.ReProMapper;
import com.yunang.officialweb.mapper.TotalMapper;
import com.yunang.officialweb.service.ReProService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author duan
 * @date 2022/12/1 13:19
 */
@Service
public class ReProServiceImpl implements ReProService {
    @Resource
    private TotalMapper totalMapper;

    @Resource
    private HomeMapper homeMapper;

    //zte
    @Resource
    private ReProMapper reProMapper;

    //
    @Override
    public TotalDesc selectViewDesc() {
        return totalMapper.selectById(6);
    }

    @Override
    public Boolean updateViewDesc(TotalDesc totalDesc) {
        totalDesc.setId(6);
        return homeMapper.updateTotalDesc(totalDesc);
    }

    @Override
    public TotalDesc selectProductionTitle() {
        return homeMapper.getTotalDesc(7);
    }

    @Override
    public Boolean updateProductionTitle(TotalDesc totalDesc) {
        totalDesc.setId(7);
        return homeMapper.updateTotalDesc(totalDesc);
    }

    @Override
    public List<ProductionDesc> selectProductionDesc(){
        return reProMapper.selectProductionDesc();
    }

    @Override
    public Boolean updateProductionDesc(int id, ProductionDesc productionDesc) {
        productionDesc.setId(id);
        return reProMapper.updateProductionDesc(productionDesc);
    }

    @Override
    public Map<String, Object> getPageOfRecPro() {
        Map<String, Object> resultMap = new HashMap<>();

        Map<String, String> vieDes = new HashMap<>();
        vieDes.put("viewDescTitle", selectViewDesc().getChineseName());
        vieDes.put("viewDescText", selectViewDesc().getText());

        Map<String, String> proTit = new HashMap<>();
        proTit.put("title", selectProductionTitle().getChineseName());
        proTit.put("recentProduction", selectProductionTitle().getText());
        proTit.put("recentProductionDesc", selectProductionTitle().getDesc1());

        resultMap.put("viewDesc", vieDes);
        resultMap.put("productionTitle", proTit);
        resultMap.put("productionDesc", reProMapper.selectProductionDesc());

        return resultMap;
    }


}
